from LogisticsCard.models import Menu
from django.utils import timezone

menu_data = [
    # 名称, 图标, 链接, 排序, 权限, 状态, 备注
    ("管理员管理", "bi-person", "/users/", 1, 1, True, "管理员管理"),
    ("用户管理", "bi-person", "/normal_users/", 2, 2, True, "普通用户管理"),
    ("卡管理", "bi-card-list", "/cards/", 3, 0, True, "卡管理"),
    ("订单中心", "bi-file-earmark", "/orders/", 4, 0, True, "订单中心"),
    ("我的地址", "bi-house", "/address/", 5, 0, True, "地址管理"),
    ("客户管理", "bi-person", "/customer/", 6, 1, True, "客户管理"),
    ("卡池管理", "bi-box", "/pool/", 7, 0, True, "卡池管理"),
    ("销户列表", "bi-x", "/pool/deactivation/", 8, 0, True, "销户列表"),
    ("用户流量池", "bi-cloud", "/flowpool/", 9, 2, True, "用户流量池"),
    ("消费明细", "bi-currency-yen", "/fee/", 10, 2, True, "消费明细"),
    ("卡流量预警", "bi-exclamation-circle", "/warning/flow/", 11, 0, True, "卡流量预警"),
    ("流量预警记录", "bi-bar-chart", "/warning/flow_record/", 12, 0, True, "流量预警记录"),
    ("卡到期提醒", "bi-clock", "/warning/expire/", 13, 0, True, "卡到期提醒"),
    ("权限管理", "bi-key", "/permissions/", 14, 1, False, "权限管理"),
    ("角色管理", "bi-person", "/roles/", 15, 1, False, "角色管理"),
    ("操作日志", "bi-list-task", "/logs/", 16, 1, False, "操作日志"),
    ("定时任务管理", "bi-clock", "/tasks/", 17, 1, True, "定时任务管理"),
    ("系统参数配置", "bi-gear", "/system_config/", 18, 1, True, "系统参数配置"),
    ("资费包管理", "bi-box", "/package/", 19, 1, True, "资费包管理"),
    ("菜单管理", "bi-menu-button", "/menu/", 20, 1, True, "菜单管理"),
    ("Django后台", "bi-tools", "/admin/", 21, 1, True, "Django后台"),
]

def batch_add_menu():
    for name, icon, url, order, permission, status, remark in menu_data:
        if not Menu.objects.filter(name=name, url=url).exists():
            Menu.objects.create(
                name=name,
                icon=icon,
                url=url,
                order=order,
                permission=permission,
                status=status,
                remark=remark,
                is_active=True,
                created_at=timezone.now(),
                updated_at=timezone.now(),
            )

if __name__ == "__main__":
    batch_add_menu()
